package com.elh.aop.factory;

import cn.hutool.core.util.ArrayUtil;
import com.elh.aop.aspect.Aspect;

/**
 * @author liulei
 **/
public abstract class AbstractProxyFactory {

    public <T> AbstractProxyFactory createProxyFactory(T target, Class<? extends Aspect> clazz) throws Exception{
        Class<?>[] interfaces = clazz.getInterfaces();
        AbstractProxyFactory abstractProxyFactory = null;
        if (ArrayUtil.isNotEmpty(interfaces)) {
            abstractProxyFactory = new JdkProxyFactory();
        } else {
            abstractProxyFactory = new CglibProxyFactory();
        }
        return abstractProxyFactory;
    }

    public abstract  <T>  T createProxyBean(T target, Class<? extends Aspect> clazz) throws Exception;

}
